package com.spring.arch.job.service;

import com.spring.arch.common.exception.ExceptionHolder;
import com.spring.arch.job.model.JobGroup;
import com.spring.arch.job.repository.JobGroupRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import static com.spring.arch.job.common.errorcode.JobErrorCode.E1015000001;


/**
 * JobGroup实体对应的业务逻辑Service实现类
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class JobGroupService {

    private JobGroupRepository jobGroupRepository;

    @Autowired
    public JobGroupService(JobGroupRepository jobGroupRepository){
        this.jobGroupRepository = jobGroupRepository;
    }

    public JobGroup findById(Integer jobGroup) {
        return jobGroupRepository.findById(jobGroup)
                .orElseThrow(() -> ExceptionHolder.serviceException(E1015000001, JobGroup.class.getSimpleName()));
    }
}
